#include "pm/project.h"

using namespace pm;

const wxString Project::TABLE_NAME   = wxT("projects");

Project::Project()
: db::Object()
{
}

Project::Project(wxSQLite3ResultSet& res)
: db::Object(res)
, m_name(res.GetString(wxT("name")))
{
}

db::update_value_type Project::prepare_insert(wxSQLite3Database& db)
{
	wxSQLite3Statement stmt = db.PrepareStatement("insert into projects values(null, ?)");
	stmt.Bind(1, m_name);
	return db::update_value_type(true, stmt);
}

db::update_value_type Project::prepare_update(wxSQLite3Database& db)
{
	wxSQLite3Statement stmt = db.PrepareStatement("update projects set name = ? where id = ?");
	stmt.Bind(1, m_name);
	stmt.Bind(2, id());
	return db::update_value_type(true, stmt);}
